//package com.zq.aspect;
//
//import com.zq.com.zq.cache.exception.LockException;
//import com.zq.com.zq.cache.exception.OptimisticLockNotFounException;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//
///**
// * Created by system.out on 2017/3/22.
// */
//@Aspect
//@Component
//public class OptimisticLockAspect {
//    private final static Logger logger = LoggerFactory.getLogger(OptimisticLockAspect.class);
//    private final int repeatNum=1000;
//    @Pointcut("@annotation(com.zq.common.annotation.OptimisticLock)")
//    private void optimisticLock(){}
//
//    @Around("optimisticLock()")
//    public Object around(ProceedingJoinPoint pjp){
//        int repeat=1;
//        while (repeat<=repeatNum){
//            try {
//                Object o = pjp.proceed();
//                return o;
//            }catch (OptimisticLockNotFounException e){
//                logger.info("未获取乐观锁进入重试........");
//                repeat++;
//            }catch (LockException e){
//                logger.error("OptimisticLockAspect LockException ....{}",e);
//                break;
//            }catch (Throwable e) {
//                logger.error("OptimisticLockAspect Throwable ....{}",e);
//                break;
//            }
//        }
//        return null;
//    }
//}
